package com.typhoon.spring_jdbctemplate.util.ratelimit;


/**
 * 单条限制规则
 * 
 * @author Typhoon
 * @date 2017-06-08 15:09
 * @since V2.0
 */
public class LimitRule {

    /**
     * 单位时间
     */
    private int seconds;

    /**
     * 单位时间内限制的访问次数
     */
    private int limitCount;

    private int lockCount;

    /**
     * 锁定时间 单位：秒
     */
    private int lockTime;



    public LimitRule() {}



    public LimitRule(int seconds, int limitCount) {
        super();
        this.seconds = seconds;
        this.limitCount = limitCount;
    }



    public LimitRule(int seconds, int limitCount, int lockCount, int lockTime) {
        super();
        this.seconds = seconds;
        this.limitCount = limitCount;
        this.lockCount = lockCount;
        this.lockTime = lockTime;
    }



    public int getSeconds() {
        return seconds;
    }

    public void setSeconds(int seconds) {
        this.seconds = seconds;
    }

    public int getLimitCount() {
        return limitCount;
    }

    public void setLimitCount(int limitCount) {
        this.limitCount = limitCount;
    }

    public int getLockCount() {
        return lockCount;
    }

    public void setLockCount(int lockCount) {
        this.lockCount = lockCount;
    }

    public int getLockTime() {
        return lockTime;
    }

    public void setLockTime(int lockTime) {
        this.lockTime = lockTime;
    }

    public boolean enableLimitLock() {
        return getLockTime() > 0 && getLockCount() > 0;
    }
}
